package com.film.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.film.domain.Film;
import com.film.service.ClassifiedFilmService;
import com.film.service.impl.ClassifiedFilmServiceImpl;

/**
 * 该控制类用来做电影的排序
 * @author 2119196781
 *
 */
@WebServlet("/classifyFilmSort.do")
public class ClassifyFilmSortController extends HttpServlet{
	private ClassifiedFilmService classifiedFilmService = new ClassifiedFilmServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//正在热映
				String title = request.getParameter("title");
				//电影类型
				String types = request.getParameter("types");
				//电影产地
				String area = request.getParameter("area");
				//上映时间
				String years= request.getParameter("years");
				//排序方式
				String text  = request.getParameter("text");
				//页码
				String pageNum = request.getParameter("pageNum");
				
				
				String flag1 = request.getParameter("flag1");
				String flag2 = request.getParameter("flag2");
				String flag3 = request.getParameter("flag3");
				String flag4 = request.getParameter("flag4");
				String flage = request.getParameter("flage");
				if("2".equals(pageNum)) {
					pageNum = "1";
				}
				List<Film> film = classifiedFilmService.selectClassifiedFilms(title, types, area, years,text);
			
					
					request.getSession().setAttribute("films", film);
//					request.getSession().setAttribute("films", allFilms);
					response.sendRedirect("showFilm.jsp?flag1="+flag1+"&flag2="+flag2+"&flag3="+flag3+"&flage="+flage+"&flag4="+flag4+"&flag="+pageNum);
//				}
				
	}
}
